package
{
	/**
	 * @author kings
	 * @E-mail: qywangweiqiang@126.com
	 * 2012-11-30上午12:16:56
	 * */
	import event.UIEditsEventName;

	import fl.controls.Button;
	import fl.controls.TextInput;

	import flash.display.Bitmap;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.utils.describeType;
	import flash.utils.getQualifiedClassName;

	import kingsAsLib.events.EventManager;
	import kingsAsLib.events.KEvents;
	import kingsAsLib.nets.KLoader;
	import kingsAsLib.air.KFileDirectory;

	import layer.LayerManagePan;

	import save.DecodeAS;
	import save.SaveCodeWins;

	import utils.ClassNameImport;

	[SWF(width="1200", height="600")]
	public class Main extends Sprite
	{

		public function Main()
		{
			super();

			this.addEventListener(Event.ADDED_TO_STAGE, inits);
		}

		protected function inits(event:Event):void
		{
			EventManager.addEventListener(UIEditsEventName.loadFileListComplete, initUI);

			EventManager.addEventListener(UIEditsEventName.saveCodeWinShow, saveCodeWin);

			EventManager.addEventListener(UIEditsEventName.LoadPic, loadBgPicHandle);

			LoadFileList.getInstance().loadFileList();
		}

		private function loadBgPicHandle(e:KEvents):void
		{
			// 
			var kfile:KFileDirectory=new KFileDirectory();
			kfile.browse(getPicURL);


		}

		private function getPicURL(urlStr:String):void
		{
			// 
			var load:KLoader=new KLoader();
			load.loaderStars(urlStr, loadPicCompleteFun);
		}

		private function loadPicCompleteFun(obj:Bitmap):void
		{
			// 
			UIView.instance().setBgBitmap(obj);
		}

		private function saveCodeWin(e:KEvents):void
		{
			// 
			var isShow:Boolean=e.getData();
			if (isShow)
			{
				addChild(SaveCodeWins.instance());
			}
			else
			{
				removeChild(SaveCodeWins.instance());
			}
		}

		private function initUI(e:KEvents):void
		{
			// 
			var _import:ClassNameImport;
			addChild(ClassLibUI.instance());
			addChild(UIView.instance());
			addChild(PropertyUI.instance());
			addChild(LayerManagePan.instance());
			addChild(MenuUI.instance());


			UIView.instance().setBgSize();

			PropertyUI.instance().setBgSize();

			setPosition();

			//注册下
			DecodeAS.instance()

		}

		private function setPosition():void
		{
			ClassLibUI.instance().y=5;
			UIView.instance().y=5;
			PropertyUI.instance().y=5;
			LayerManagePan.instance().y=5;

			UIView.instance().x=180;
			PropertyUI.instance().x=UIView.instance().x + UIView.instance().width + 10;

			LayerManagePan.instance().x=PropertyUI.instance().x + PropertyUI.instance().width + 10;

			MenuUI.instance().y=UIView.instance().y + UIView.instance().height + 10;
		}
	}

	//end class
}
